//
//  TKYProgressViewCell.m
//  常用的类和基类
//
//  Created by apple on 2018/3/20.
//  Copyright © 2018年 铁科院. All rights reserved.
//

#import "TKYProgressViewCell.h"
@interface TKYProgressViewCell()
@property (weak, nonatomic) IBOutlet UIImageView *imageV;
@property (weak, nonatomic) IBOutlet UILabel *flowNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UIProgressView *progressView;


@property (weak, nonatomic) IBOutlet UILabel *progressLabel;

@end
@implementation TKYProgressViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.imageV.backgroundColor = kRGBColor(248, 248, 248, 1);
    //设定两端弧度
    self.progressView.layer.cornerRadius = 3.0;
    self.progressView.layer.masksToBounds = YES;
    //设置进度条的颜色
    self.progressView.progressTintColor = kRGBColor(34, 130, 255, 1);
    
    //设置进度条的当前值，范围：0~1；
    self.progressView.transform = CGAffineTransformMakeScale(1.0f, 3.0f);
    /*
     typedef NS_ENUM(NSInteger, UIProgressViewStyle) {
     UIProgressViewStyleDefault,     // normal progress bar
     UIProgressViewStyleBar __TVOS_PROHIBITED,     // for use in a toolbar
     };
     */
    self.progressView.progressViewStyle = UIProgressViewStyleDefault;
    self.imageV.contentMode=UIViewContentModeScaleAspectFill;
     self.imageV.clipsToBounds=YES;//  是否剪切掉超出 UIImageView
    //范围的图片
    [self.imageV setContentScaleFactor:[[UIScreen mainScreen] scale]];
    
}

//给label赋值
- (void)setProgressModel:(TKYProgressModel *)progressModel{
    _progressModel = progressModel;    
    if (progressModel.lastDocPath.length > 0) {
        NSData *imageData = [[NSData alloc]initWithBase64EncodedString:progressModel.lastDocPath options:(NSDataBase64DecodingIgnoreUnknownCharacters)];
        self.imageV.image = [UIImage imageWithData:imageData];

    }else{
        self.imageV.image = [UIImage imageNamed:@"default"];

    }
    //防止image变形
    self.flowNameLabel.text = [NSString stringWithFormat:@"%@:%@",progressModel.procedureName,progressModel.flowName];
    self.dateLabel.text = progressModel.createDate;
    self.progressView.progress = progressModel.percent *0.01;
    self.progressLabel.text = [NSString stringWithFormat:@"%ld%%",progressModel.percent];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
